import request from "@utils/request";

/**
 * 注册账号
 * @param username 账号
 * @param password 密码
 * @param code 邀请码
 * @returns {*}
 */
export function register(username, password, code, captcha) {
    return request({
        url: '/api/member/doRegister',
        method: 'post',
        data: {
            username,
            password,
            code,
            captcha
        }
    });
}

/**
 * 登录操作
 * @param username
 * @param password
 * @returns {*}
 */
export function login(username, password, captcha) {
    return request({
        url: '/api/member/doLogin',
        method: 'post',
        data: {
            username,
            password,
            captcha
        }
    });
}

export function getUserInfo() {
    return request({
        url: "/api/member/getUserInfo",
        method: "get"
    })
}

export function updateUserInfo(data) {
    return request({
        url: "/api/member/updateInfo",
        method: "post",
        data: data
    })
}

export function logout() {
    return request({
        url: "/api/member/doLogout",
        method: "post"
    })
}

export function updatePassword(data) {
    return request({
        url: "/api/member/setLoginPassword",
        method: "post",
        data: data
    })
}

export function updateAvatar(header_img) {
    return request({
        url: "/api/member/uploadHeaderImg",
        method: "post",
        data: {header_img}
    })
}

export function updatePayPassword(oldPassword, paypassword){
    return request({
        url: "/api/member/setPayPassword",
        method: "post",
        data:{
            oldPassword, paypassword
        }
    })
}

export function getNoticeList(){
    return request({
        url: "/api/notice/getNoticeList",
        method: "get"
    })
}

export function getWalletChangeList(limit, page){
    return request({
        url: "/api/member/moneylog",
        method: "get",
        params:{
            limit,
            page
        }
    })
}

export function getSignList(){
    return request({
        url: "/api/member/signList",
        method: "get",
    })
}

export function Sign(){
    return request({
        url: "/api/member/sign",
        method: "get",
    })
}
